package com.zcp.pcsuitall.business;

import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.channels.SocketChannel;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedList;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlSerializer;

import android.app.PendingIntent;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.util.Log;
import android.util.Xml;

import com.zcp.pcsuitall.Action;
import com.zcp.pcsuitall.BusinessControl;
import com.zcp.pcsuitall.IDealWithMessage;
import com.zcp.pcsuitall.Item;
import com.zcp.pcsuitall.XmlDataDealWith;

public class SmsInfoManager implements IDealWithMessage{
    private  SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private  Date dateTime = new Date(0l);
    private  Timestamp ts = new Timestamp(0l); 
    
    @Override
    public boolean dealWith(SocketChannel sc, Action action,Context context) {
    	boolean success = false;       	
        if (action != null) {
            String op = action.getName();
            if (op.equals("LoadSMS")) {
            	success=dealWithLoad(sc,action,context);            	
            }else if (op.equals("AddSMS")) {
            	success=dealWithAdd(sc,action,context);   
            }else if(op.equals("CleanupSMS")){
            	success = dealWithCleanup(sc, action, context);
            }else if(op.equals("DeleteSMS")){
            	success = dealWithDelete(sc, action, context);
            } else if(op.equals("ReadSMSCapacity")){
            	success = dealWithReadSMSCapacity(sc, action, context);
            } else if(op.equals("ReadSMSTotal")){
            	success = dealWithReadSMSTotal(sc, action, context);
            } else if(op.equals("SendSMS")){
            	success = dealWithSendSMS(sc, action, context);
            }
        }   
        return success;
   }
    
    protected String packageData(Action action, LinkedList<SmsInfoObject> smsInfoObjectList) {
        return null;
    }
    
    
    LinkedList<SmsInfoObject> smsList = null;
    /**
     * 处理查询短信方法。
     * @param sc
     * @param action
     * @param context
     * @return
     */
    private boolean dealWithLoad(SocketChannel sc, Action action,
			Context context) {
    	
		smsList = LoadSMS(context,action);
		try {
			String result = packageData(context,action,smsList);//以字符形式的XML输出
			BusinessControl.returnToClient(sc, result,context);
			smsList.clear();
			return true;
		} catch (Exception e) {
			Log.e(TAG, e.getMessage());
			e.printStackTrace();
			BusinessControl.returnToClient(sc,XmlDataDealWith.getSystemErrorString(action.getName(), e.toString()),context);
			return false;
		}
	}
    
    /**
     * 获取总条数
     */
    private String getSmsTatol(Context context, Action action) {
    	
		String from = XmlDataDealWith.getRegularSingle("from",action.getSource());
		String to = XmlDataDealWith.getRegularSingle("to",action.getSource());
		
		int sms_from = Integer.valueOf(from).intValue();
		int sms_to = Integer.valueOf(to).intValue();
		int sms_count = 0;
		Cursor c = null;
		try{
	    	Uri uri = Uri.parse("content://sms");
			c = context.getContentResolver().query(uri, new String[]{"count(*) as sms_count"}, null, null,null);
			c.moveToFirst();
			sms_count = c.getInt(0);
		}catch (Exception e) {
            e.printStackTrace();
		}finally{
			c.close();
		}
		
		if (sms_from <= 0 || sms_to <= 0 || sms_to < sms_from || sms_from > sms_count) {
			return null;
		}
		
		String result = "";
        if (sms_count>0) {
        	result = "<from>"+from+"</from><to>"+to+"</to><total>"+sms_count+"</total>";
        }else{
        	result = "<from>"+0+"</from><to>"+0+"</to><total>"+0+"</total>";
        }
		return result;
	}

   
	/**
     * 处理清空短信方法。
     */
    private boolean dealWithCleanup(SocketChannel sc, Action action,
			Context context) {
    	String type = XmlDataDealWith.getRegularSingle("type",action.getSource());
	    try {
	    	if(type.equals("")){
	    		BusinessControl.returnToClient(sc,XmlDataDealWith.getErrorString(action.getName(),"6", "action CleanupSms type is null"),context);
	    		return false;
	    	}else if(type.equals("0")){
	    		Log.v(TAG, "CleanupSms type is all");
	    		context.getContentResolver().delete(Uri.parse("content://sms"), null,null);
	    		BusinessControl.returnToClient(sc, "<?xml version=\"1.0\" encoding=\"utf-8\"?><root><action>CleanupSMS</action></root>",context);
	    		return true;
	    	}else{
	    		Log.v(TAG, "CleanupSms type is "+type);
	    		context.getContentResolver().delete(Uri.parse("content://sms"), "type=?", new String[]{type});
	    		BusinessControl.returnToClient(sc, "<?xml version=\"1.0\" encoding=\"utf-8\"?><root><action>CleanupSMS</action></root>",context);
	    		return true;
	    	}
		} catch (Exception e) {
			Log.e(TAG, e.getMessage());
			e.printStackTrace();
			BusinessControl.returnToClient(sc,XmlDataDealWith.getSystemErrorString(action.getName(), e.toString()),context);
			return false;
		}
    }
    
    /**
     * 处理删除短信方法。
     */
    private boolean dealWithDelete(SocketChannel sc, Action action,
    		Context context) {
    	values=XmlDataDealWith.getData(new String[]{"id"}, action.getSource());
    	if(values.isEmpty()||values.get(0).getItemData("id")==null){
    		BusinessControl.returnToClient(sc,XmlDataDealWith.getErrorString(action.getName(),"6", "action deleteSms id is null"),context);
    		return false;
    	}
    	try {
	    	for(int i=0;i<values.size();i++){
	    		if(values.get(i).getItemData("id").equals("")){
	    			continue;
	    		}
	    		Log.v(TAG, "delete sms id is "+values.get(i).getItemData("id"));
	    		context.getContentResolver().delete(Uri.parse("content://sms"), "_id=?", new String[]{values.get(i).getItemData("id")});
	    	}
	    	values.clear();
	    	BusinessControl.returnToClient(sc, "<?xml version=\"1.0\" encoding=\"utf-8\"?><root><action>DeleteSMS</action></root>",context);
    		return true;
    	} catch (Exception e) {
    		Log.e(TAG, e.getMessage());
    		e.printStackTrace();
    		BusinessControl.returnToClient(sc,XmlDataDealWith.getSystemErrorString(action.getName(), e.toString()),context);
    		return false;
    	}
    }
    
    /**
     * 处理获取短信容量方法。
     */
    private boolean dealWithReadSMSCapacity(SocketChannel sc, Action action,
    		Context context) {
    	String result = "<?xml version=\"1.0\" encoding=\"utf-8\"?><root><action>ReadSMSCapacity</action><data><capacity>1000</capacity></data></root>";
        BusinessControl.returnToClient(sc, result,context);
        return true;
    }
    
    /**
     * 处理获取短信总条数方法。
     */
    private boolean dealWithReadSMSTotal(SocketChannel sc, Action action,
    		Context context) {
    	Cursor c = null;
    	int sms_count = 0;
    	try {
    		Uri uri = Uri.parse("content://sms");
    		c = context.getContentResolver().query(uri, new String[]{"count(*) as sms_count"}, null, null,null);
    		c.moveToFirst();
    		sms_count = c.getInt(0);
    		BusinessControl.returnToClient(sc, "<?xml version=\"1.0\" encoding=\"utf-8\"?><root><action>ReadSMSTotal</action><data><total>"+sms_count+"</total></data></root>",context);
    		return true;
    	} catch (Exception e) {
    		Log.e(TAG, e.getMessage());
    		e.printStackTrace();
    		BusinessControl.returnToClient(sc,XmlDataDealWith.getSystemErrorString(action.getName(), e.toString()),context);
    		return false;
    	}finally{
    		c.close();
    	}
    }
    
    private static String SMS_SEND_ACTIOIN = "SMS_SEND_ACTIOIN";
	private static String SMS_DELIVERED_ACTION = "SMS_DELIVERED_ACTION"; 
    
	public static String getActionValue(String value,String key) {
        StringReader stringRead = new StringReader(value);
        XmlPullParser parser = Xml.newPullParser();
        String message = null;
        try {
            parser.setInput(stringRead);
            int event = parser.getEventType();// 产生第一个事件
            while (event != XmlPullParser.END_DOCUMENT) {
                switch (event) {
                    case XmlPullParser.START_TAG:// 判断当前事件是否是标签元素开始事件
                        if (parser.getDepth() == 3) {
                            if (key.equals(parser.getName())) {
                                message = parser.nextText();
                            } 
                        }
                        break;
                }
                event = parser.next();// 进入下一个元素并触发相应事件
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                parser = null;
                if (stringRead != null) {
                    stringRead.close();
                    stringRead = null;
                }
            } catch (Exception e) {

            }
        }
        return message;
    }
	
    /**
     * 处理获取短信发送的方法
     */
    private boolean dealWithSendSMS(SocketChannel sc, Action action,Context context) {
    	
    	String body = getActionValue(action.getSource(),"message");
    	System.out.println("////////////////"+body);
    	String address = XmlDataDealWith.getRegularSingle("sendToPhone",action.getSource());
    	String send_id = XmlDataDealWith.getRegularSingle("send_id",action.getSource());
    	Log.v(TAG, "dealWithSendSMS message--"+body+"--address"+address);
    	
    	
    	long date = System.currentTimeMillis();
    	
    	String[] phones = address.split(";");//一次发送多条短信，号码用;隔开
    	if(phones.length>0){
    		for(int i=0;i<phones.length;i++){
    			
    			ArrayList<PendingIntent> sendIntents = new ArrayList<PendingIntent>();
    			ArrayList<PendingIntent> deliverIntents = new ArrayList<PendingIntent>();
    			
    			Intent itSend = new Intent(SMS_SEND_ACTIOIN);
    			Intent itDeliver = new Intent(SMS_DELIVERED_ACTION);
    			Bundle bundle=new Bundle();
    			bundle.putString(ADDRESS, phones[i]);
    			bundle.putString(BODY, body);
    			bundle.putString("send_id", send_id);
    			bundle.putString(DATE, date+"");
    			itSend.putExtra("bundle", bundle);
    			
    			PendingIntent mSendPI = PendingIntent.getBroadcast(context, 0, itSend, PendingIntent.FLAG_CANCEL_CURRENT);        
    			PendingIntent mDeliverPI = PendingIntent.getBroadcast(context, 0, itDeliver, PendingIntent.FLAG_CANCEL_CURRENT);
    			
    			SmsManager sms = SmsManager.getDefault();
    			ArrayList<String> messageArray = sms.divideMessage(body);
    			
				sendIntents.add(mSendPI);
				deliverIntents.add(mDeliverPI);
    			
    			sms.sendMultipartTextMessage(phones[i], null, messageArray, sendIntents, deliverIntents);
    			//sms.sendTextMessage(phones[i], null, body, mSendPI , mDeliverPI);
    		}
    	}
    	BusinessControl.returnToClient(sc, "<?xml version=\"1.0\" encoding=\"utf-8\"?><root><action>SendSMS</action><data><send_id>"+send_id+"</send_id></data></root>",context);
		return true;
    }
    
    private String[] ADD_KEYS=
    new String[] {
            "id", "number", "address", "person_id", "date", "protocol", "is_read", "status",
            "type", "reply_path_present", "subject", "body", "service_center", "locked"
    };
    
    private LinkedList<Item> values=null;
    private LinkedList<ContentValues> contentValueList = new LinkedList<ContentValues>();
    private Item item=null;
    
    /**
     * 处理添加短信方法。
     */
    private boolean dealWithAdd(SocketChannel sc, Action action,
			Context context) {
    	//values=XmlDataDealWith.getData(ADD_KEYS, action.getSource());
    	values= XmlDataDealWith.getDataByXml(ADD_KEYS, action.getSource(), 3, 1);
    	
    	try{
    		
    		if(values.isEmpty()){
    			BusinessControl.returnToClient(sc,XmlDataDealWith.getErrorString(action.getName(),"6", "action AddSms values is empty"),context);
    		}else{
    			long beginTime = System.currentTimeMillis(); 
    			
    			ContentValues contentValue = null;
    			int size=values.size();
    			
    			item=null;
    			contentValueList.clear();
    			for(int i=0;i<size;i++){
    				item=values.get(i);
    				if(values.get(i).getItemData(DATE).equals("")&&item.getItemData(ADDRESS).equals("")){
    					Log.v(TAG, "address and date is null");
    					continue;
    				}
    				contentValue = new ContentValues();
    				//contentValue.put(THREADID, item.getItemData(THREADID));
    				contentValue.put(ADDRESS, item.getItemData(ADDRESS));
    				contentValue.put(PERSON, item.getItemData(PERSON_ID));
    				//把时间格式的字符串转换成系统需要的long类型插入数据库
    				contentValue.put(DATE, String.valueOf(ts.valueOf((item.getItemData(DATE))).getTime()));
    				contentValue.put(PROTOCOL, item.getItemData(PROTOCOL));
    				contentValue.put(READ, item.getItemData(IS_READ));
    				contentValue.put(STATUS, item.getItemData(STATUS));
    				contentValue.put(TYPE, item.getItemData(TYPE));
    				contentValue.put(REPLYPATHPRESENT, item.getItemData(REPLYPATHPRESENT));
    				contentValue.put(SUBJECT, item.getItemData(SUBJECT));
    				contentValue.put(BODY, item.getItemData(BODY));
    				contentValue.put(SERVICECENTER, item.getItemData(SERVICECENTER));
    				contentValue.put(LOCKED, item.getItemData(LOCKED));
    				contentValueList.add(contentValue);
    				item=null;
    				
    			}
				context.getContentResolver().bulkInsert(Uri.parse("content://sms"), contentValueList.toArray(new ContentValues[0]));
				
				 //计算运行时间值  
    			long endTime = System.currentTimeMillis();  
    			
    			long period = endTime - beginTime;     			
    			BusinessControl.returnToClient(sc, "<?xml version=\"1.0\" encoding=\"utf-8\"?><root><action>AddSMS</action></root>",context);
    			Log.v(TAG, String.valueOf(period/1000));
    		}
    	}catch(Exception e){
    		Log.e(TAG, e.getMessage());
    		e.printStackTrace();
    		BusinessControl.returnToClient(sc,XmlDataDealWith.getSystemErrorString(action.getName(), e.toString()),context);
			return false;
    	}
    	values.clear();
    	contentValueList.clear();
    	return true;
	}
    
    
    
    LinkedList<SmsInfoObject> resultList = new LinkedList<SmsInfoObject>();
    /**
	 * 查询短信消息。
	 * @param context
	 * @return
	 */
	private LinkedList<SmsInfoObject> LoadSMS(Context context,Action action) {
		resultList.clear();
		SmsInfoObject element = null;
		Cursor c = null;
		Cursor c2 = null;
		
		int id = 0;
		int thread_id = 0;
		String address = "";
		long person = 0l;
		long date = 0l;
		int protocol = 0;
		int read = 0;
		int status = 0;
		int type = 0;
		String reply_path_present = "";
		String subject = "";
		String body = "";
		String service_center = "";
		String locked = "";
		
		
		String from_type = XmlDataDealWith.getRegularSingle("type",action.getSource());
		String from = XmlDataDealWith.getRegularSingle("from",action.getSource());
		String to = XmlDataDealWith.getRegularSingle("to",action.getSource());
		String where_clause = null;
		if(!from_type.equals("0")){
			where_clause = "type = "+from_type;
		}
		int sms_from = Integer.valueOf(from).intValue();
		int sms_to = Integer.valueOf(to).intValue();
		int limit = sms_to-(sms_from-1);
		int offset = sms_from-1;
		
		try{
			Uri uri = Uri.parse("content://sms");
			c = context.getContentResolver().query(uri, null, where_clause, null,"_id ASC LIMIT "+limit+" OFFSET "+offset);
			
				boolean have=c.moveToFirst();
				if(have){
					do {
						element = new SmsInfoObject();
						id = c.getInt(c.getColumnIndex("_id"));
						element.setId(String.valueOf(id));
						thread_id = c.getInt(c.getColumnIndex("thread_id"));
						element.setThread_id(String.valueOf(thread_id));
						address = c.getString(c.getColumnIndex(ADDRESS));
						
						if(address == null){
							Uri uri2 = Uri.parse("content://mms-sms/canonical-addresses");
							c2 = context.getContentResolver().query(uri2, null, "_id="+thread_id, null,null);
							if(c2.moveToFirst()){
								do{
									address = c2.getString(c2.getColumnIndex(ADDRESS));
									break;
								} while(c2.moveToNext());
							}
							 c2.close();
						}
						
						element.setAddress(String.valueOf(address));
						person = c.getLong(c.getColumnIndex(PERSON));
						element.setPerson_id(String.valueOf(person));
						date = c.getLong(c.getColumnIndex(DATE));
						//element.setDate(String.valueOf(date));
						//把long类型转换成PC端需要的时间格式输出
						dateTime.setTime(Long.parseLong(String.valueOf(date)));
						element.setDate(dateFormat.format(dateTime));
						
						protocol = c.getInt(c.getColumnIndex(PROTOCOL));
						element.setProtocol(String.valueOf(protocol));
						read = c.getInt(c.getColumnIndex(READ));
						element.setIs_read(String.valueOf(read));
						status = c.getInt(c.getColumnIndex(STATUS));
						element.setStatus(String.valueOf(status));
						type = c.getInt(c.getColumnIndex(TYPE));
						element.setType(String.valueOf(type));
						reply_path_present = c.getString(c.getColumnIndex(REPLYPATHPRESENT));
						element.setReply_path_present(reply_path_present);
						subject = c.getString(c.getColumnIndex(SUBJECT));
						element.setSubject(subject);
						body = c.getString(c.getColumnIndex(BODY));
						element.setBody(body);
						service_center = c.getString(c.getColumnIndex(SERVICECENTER));
						element.setservice_center(service_center);
						locked = c.getString(c.getColumnIndex(LOCKED));
						element.setLocked(locked);
			
						resultList.add(element);
					} while (c.moveToNext());
				}
			} catch (Exception e) {
	            e.printStackTrace();
	        } finally {
	            c.close();
	        }
		return resultList;
	}
	
	/**
     * 使用StringBuffer处理短信，输出字符形式的XML
     * @param smsInfoObjectList
     * @return StringBuffer toString
     */
    private String packageData(Context context,Action action,LinkedList<SmsInfoObject> smsInfoObjectList){
    	
    	StringWriter writer = new StringWriter();
        XmlSerializer serializer = Xml.newSerializer();
        try {
            serializer.setOutput(writer);
            XmlDataDealWith.createPre(action, serializer);
            if (smsInfoObjectList != null) {

                for (SmsInfoObject element : smsInfoObjectList) {
                    serializer.startTag(SPACE, ITEM);

                    serializer.startTag(SPACE, ID);
                    serializer.text(element.getId() != null ? element.getId() : SPACE);
                    serializer.endTag(SPACE, ID);

                    serializer.startTag(SPACE, THREADID);
                    serializer.text(element.getThread_id() != null ? element.getThread_id() : SPACE);
                    serializer.endTag(SPACE, THREADID);
                    
                    serializer.startTag(SPACE, ADDRESS);
                    serializer.text(element.getAddress() != null ? element.getAddress() : SPACE);
                    serializer.endTag(SPACE, ADDRESS);

                    serializer.startTag(SPACE, PERSON_ID);
                    serializer.text(element.getPerson_id() != null ? element.getPerson_id() : SPACE);
                    serializer.endTag(SPACE, PERSON_ID);
                    
                    serializer.startTag(SPACE, DATE);
                    serializer.text(element.getDate() != null ? element.getDate() : SPACE);
                    serializer.endTag(SPACE, DATE);
                    
                    serializer.startTag(SPACE, PROTOCOL);
                    serializer.text(element.getProtocol() != null ? element.getProtocol() : SPACE);
                    serializer.endTag(SPACE, PROTOCOL);
                    
                    serializer.startTag(SPACE, IS_READ);
                    serializer.text(element.getIs_read() != null ? element.getIs_read() : SPACE);
                    serializer.endTag(SPACE, IS_READ);
                    
                    serializer.startTag(SPACE, STATUS);
                    serializer.text(element.getStatus() != null ? element.getStatus() : SPACE);
                    serializer.endTag(SPACE, STATUS);
                    
                    serializer.startTag(SPACE, TYPE);
                    serializer.text(element.getType() != null ? element.getType() : SPACE);
                    serializer.endTag(SPACE, TYPE);
                    
                    serializer.startTag(SPACE, REPLYPATHPRESENT);
                    serializer.text(element.getReply_path_present() != null ? element.getReply_path_present() : SPACE);
                    serializer.endTag(SPACE, REPLYPATHPRESENT);
                    
                    serializer.startTag(SPACE, SUBJECT);
                    serializer.text(element.getSubject() != null ? element.getSubject() : SPACE);
                    serializer.endTag(SPACE, SUBJECT);
                    
                    serializer.startTag(SPACE, BODY);
                    serializer.text(element.getBody()!= null ? element.getBody().trim() : SPACE);
                    serializer.endTag(SPACE, BODY);
                    
                    serializer.startTag(SPACE, SERVICECENTER);
                    serializer.text(element.getservice_center()!= null ? element.getservice_center() : SPACE);
                    serializer.endTag(SPACE, SERVICECENTER);
                    
                    serializer.startTag(SPACE, LOCKED);
                    serializer.text(element.getLocked()!= null ? element.getLocked() : SPACE);
                    serializer.endTag(SPACE, LOCKED);

                    serializer.endTag(SPACE, ITEM);
                }
            }
            serializer.endTag(SPACE, DATA);

            String from = XmlDataDealWith.getRegularSingle("from",action.getSource());
    		String to = XmlDataDealWith.getRegularSingle("to",action.getSource());
    		
    		int sms_from = Integer.valueOf(from).intValue();
    		int sms_to = Integer.valueOf(to).intValue();
    		int sms_count = getTotol(context);
    		
    		if (sms_from <= 0 || sms_to <= 0 || sms_to < sms_from || sms_from > sms_count) {
    			return "<?xml version=\"1.0\" encoding=\"utf-8\"?><root><action>LoadSMS</action><data></data><from></from><to></to><total></total></root>";
    		}
    		
            if (sms_count>0) {
            	serializer.startTag(SPACE, FROM);
                serializer.text(from);
                serializer.endTag(SPACE, FROM);

                serializer.startTag(SPACE, TO);
                serializer.text(to);
                serializer.endTag(SPACE, TO);

                serializer.startTag(SPACE, TOTAL);
                serializer.text(sms_count+"");
                serializer.endTag(SPACE, TOTAL);
            }else{
            	serializer.startTag(SPACE, FROM);
                serializer.text(0+"");
                serializer.endTag(SPACE, FROM);

                serializer.startTag(SPACE, TO);
                serializer.text(0+"");
                serializer.endTag(SPACE, TO);

                serializer.startTag(SPACE, TOTAL);
                serializer.text(0+"");
                serializer.endTag(SPACE, TOTAL);
            }
            
            serializer.endTag(SPACE, ROOT);
            serializer.endDocument();
            return writer.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return XmlDataDealWith.getSystemErrorString(action.getName(), e.toString());
        } finally {
            serializer = null;
            try {
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            writer = null;
        }
    }
    
    public int getTotol(Context context){
    	Cursor c = null;
    	int total = 0;
		try{
	    	Uri uri = Uri.parse("content://sms");
			c = context.getContentResolver().query(uri, new String[]{"count(*) as sms_count"}, null, null,null);
			c.moveToFirst();
			total = c.getInt(0);
		}catch (Exception e) {
            e.printStackTrace();
		}finally{
			c.close();
		}
		return total;
    }
    
    private String ID="id";
    private String THREADID="thread_id";
    private String ADDRESS="address";
    private String PERSON="person";
    private String DATE="date";
    private String PROTOCOL="protocol";
    private String READ="read";
    private String STATUS="status";
    private String TYPE="type";
    private String REPLYPATHPRESENT="reply_path_present";
    private String SUBJECT="subject";
    private String BODY="body";
    private String SERVICECENTER="service_center";
    private String LOCKED="locked";
    private String PERSON_ID="person_id";
    private String IS_READ="is_read";
    
    private String SPACE = "";

    private String ITEM = "item";

    private String DATA = "data";

    private String FROM = "from";

    private String TO = "to";

    private String TOTAL = "total";

    private String ROOT = "root";

    private String NOSETTING = "notSetting";
    private static String TAG = "SmsManager";
}
